package com.akk.module.access.service;

import com.akk.module.access.entity.AccessBank;
import com.akk.module.access.entity.AccessBankExample;
import com.akk.module.access.mapper.AccessBankMapper;
import com.akk.module.access.mapper.dao.AccessBankDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

@Service
public class AccessBankService {


    @Autowired
    private AccessBankDao bankDao;

    @Autowired
    private AccessBankExample bankExample;

    @Autowired
    private AccessBankMapper bankMapper;

    @Transactional
    public List<Map> queryBankByIndex(){
        List<String> list = bankDao.selectAllIndex();
        List<Map> result = new ArrayList<>();
        for (String str:list) {
            if (str.isEmpty())
                continue;
            Map map = new HashMap();
            List<AccessBank> banks = bankDao.selectBankByGrepIndex(str);
            banks.sort(Comparator.comparing(AccessBank::getBankName));
            map.put(str,banks);
            result.add(map);
        }
        return result;
    }

}
